#include <set>
#include <vector>
#include <utility>
#include <fstream>
#include <iostream>

using namespace std;

set<int> measure;

void backAndForth(
  int days, 
  pair<int, vector<int>> shed1, 
  pair<int, vector<int>> shed2) {
  
  if (days == 5) {
    measure.insert(shed1.first);
    return;
  }

  // 把 shed1 的每一个桶都拿到 shed2 去试一遍
  for (int i = 0; i < shed1.second.size(); ++i) {
    int b = shed1.second[i]; // b 是要拿到 shed2 去的

    vector<int> x = shed1.second;
    x.erase(x.begin() + i);

    vector<int> y = shed2.second;
    y.push_back(b);

    backAndForth(days + 1, {shed2.first + b, y}, {shed1.first - b, x});
  }
}

int main(int argc, char const *argv[])
{
  vector<int> buckets;

  ifstream ifs("BackAndForth.in");

  for (int i = 0; i < 10; ++i) {
    int n;
    ifs >> n;
    buckets.push_back(n);
  }

  pair<int, vector<int>> shed1 {1000, buckets};

  buckets = {};
  for (int i = 0; i < 10; ++i) {
    int n;
    ifs >> n;
    buckets.push_back(n);
  }
  pair<int, vector<int>> shed2 {1000, buckets};

  ofstream ofs("BackAndForth.out");
  backAndForth(1, shed1, shed2);
  ofs << measure.size();
  
  return 0;
}
